package adapter;

public class ExtentsAndImplements {
    /**
     * 这块代码打开注释，FatherRootClass()、FatherRootAbstract()、ChildrenClass()
     * 上面这一串构造函数会在 System.out.println(" call Main() ................") 与 主类构造函数 ExtentsAndImplements() 之间执行【比较不好理解】。
     **/
    ChildrenClass childrenClass = new ChildrenClass();

    ExtentsAndImplements() {
        System.out.println(" 主类无参构造函数执行：ExtentsAndImplements construct 11111111111111111111");
    }

    public static void main(String[] args) {
        System.out.println(" call Main() ................");
        ChildrenClass childrenClass = new ExtentsAndImplements().new ChildrenClass(" new ChildrenClass(param) : ");
        System.out.println(" ChildrenClass test() ................");
        childrenClass.test();
    }

    class FatherRootClass {
        private FatherRootClass() {
            System.out.println(" FatherRootClass No construct !!!=================");
        }

        private FatherRootClass(String FatherRootClass) {
            System.out.println(FatherRootClass + " FatherRootClass construct !!!=================");
        }
    }

    interface SimpleRootInterface {
        void run();
    }

    abstract class FatherRootAbstract extends FatherRootClass implements SimpleRootInterface {
        public FatherRootAbstract() {
            System.out.println(" FatherRootAbstract extends FatherRootClass No construct !!!  #######################");
        }

        public FatherRootAbstract(String FatherRootAbstract) {
            super(FatherRootAbstract);
            System.out.println(FatherRootAbstract + " FatherRootAbstract extends FatherRootClass construct !!!  #######################");
        }

        abstract void excute();

        @Override
        public void run() {
            this.excute();
            System.out.println(" FatherRootAbstract implements SimpleRootInterface.run(). " +
                    "this is FatherRootAbstract'run(). ------333333333333333333333");
        }

    }

    class ChildrenClass extends FatherRootAbstract {
        public ChildrenClass() {
            System.out.println(" ChildrenClass extends FatherRootAbstract No construct !!!  @@@@@@@@@@@@@@@@@@@@");
        }

        public ChildrenClass(String begin) {
            super(begin);
            System.out.println(begin + " ChildrenClass extends FatherRootAbstract construct !!!  @@@@@@@@@@@@@@@@@@@@");
        }

        private void test() {
//            super.run();
            this.run();
            this.excute();
            System.out.println(" SUCCESS!");
        }

        @Override
        public void excute() {
            System.out.println(" ChildrenClass extends FatherRootAbstract implements SimpleRootInterface. " +
                    "this is ChildrenClass'excute(). ------666666666666666666666");
        }
    }
}
